package com.ydj.app.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.ydj.app.entity.CmsAccount;
import com.ydj.app.protocol.http.cms.*;
import com.ydj.app.service.KolService;
import com.ydj.app.service.WebUserService;
import com.ydj.framework.exception.CommonException;
import com.ydj.framework.protocol.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

@RestController
@RequestMapping("/cms/webUser")
@Api(tags = "CMS-用户")
public class CmsWebUserController {
    @Autowired
    private WebUserService webUserService;

    @ResponseBody
    @ApiOperation(value = "列表")
    @ApiOperationSupport(order = 10)
    @PostMapping(value = "/list")
    public JsonResult<CmsWebUserListRes> list(@RequestBody @Validated CmsWebUserListReq req, @ApiIgnore CmsAccount account) throws CommonException {
        CmsWebUserListRes res = webUserService.cmsList(req, account);
        return JsonResult.success(res);
    }

    @ResponseBody
    @ApiOperation(value = "更改会员等级")
    @ApiOperationSupport(order = 20)
    @PostMapping(value = "/updateLevel")
    public JsonResult<?> create(@RequestBody @Validated CmsWebUserUpdateLevelReq req, @ApiIgnore CmsAccount account) throws CommonException {
        webUserService.cmsUpdateLevel(req, account);
        return JsonResult.success();
    }

}